package ltTest.controller;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import ltTest.entity.CategoryMini;
import ltTest.entity.User;
import ltTest.server.impl.TestServiceImpl;

@RestController
@RequestMapping("/test")
public class TestController {

	@Autowired
	private TestServiceImpl testServiceImpl;
	
	@Autowired
	private RedisTemplate<String, String> redisTemplate;
	
	
	@RequestMapping("/user")
	public User tset(User user , HttpServletRequest request){
		System.out.println("controller : " + user);
		if(user != null){
			user.setAdd(testServiceImpl.add(user.getX(), user.getY()));
		}
		user.setDate(new Date());
//		throw new NullPointerException("!!!!");
		return user;
	}
	
	@RequestMapping("aa")
	public User aa(CategoryMini user){
		String randomKey = redisTemplate.randomKey();
		System.out.println(randomKey);
		return new User();
	}
	
}
